#include "app.h"

namespace cores
{
    namespace apps
    {
        App * App::globalApp = nullptr;

        App::App()
        {
            if (App::globalApp == nullptr)
            {
                App::globalApp = this;
            }
        }

        App::~App()
        {
            if (App::globalApp == this)
            {
                App::globalApp = nullptr;
            }
        }

        void App::Initialize()
        {
            if (App::globalApp == nullptr)
                return;

            App::globalApp->initialize();
        }

        void App::Finalize()
        {
            if (App::globalApp == nullptr)
                return;

            App::globalApp->finalize();
        }

        int App::Run()
        {
            if (App::globalApp == nullptr)
                return -1;

            return App::globalApp->run();
        }
    }
}